package com.worldstear.core;

import lombok.*;

import java.io.Serializable;

@Data
@Builder
@AllArgsConstructor
@Setter
@Getter
public class R<T> implements Serializable {

    private T data;
    private String msg;
    private Long code;

    public static final String SUCCESS_MSG = "SUCCESS";
    public static final Long SUCCESS_CODE = 200L;
    public static final Long ERROR_CODE = 500L;
    public static <T> R<T> success() {
        return new R<T>(null, SUCCESS_MSG, SUCCESS_CODE);
    }
    public static <T> R<T> success(T data) {
        return new R<T>(data, SUCCESS_MSG, SUCCESS_CODE);
    }
    public static <T> R<T> error(String msg) {
        return new R<T>(null, msg, ERROR_CODE);
    }
}
